/********************************************************************************
 *      Copyright:  (C) 2025 ZYT
 *                  All rights reserved.
 *
 *       Filename:  pack.h
 *    Description:  This file 
 *
 *        Version:  1.0.0(01/05/25)
 *         Author:  Zhang yuting <zhangyuting@163.com>
 *      ChangeLog:  1, Release initial version on "01/05/25 16:31:18"
 *                 
 ********************************************************************************/
#ifndef __PACK_H__
#define __PACK_H__

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdint.h>
#include <arpa/inet.h>

#include "logger.h"
#define CRC16_ITU_T_POLY 0x1021

typedef struct pack
{
	char 	dev_sn[32];
	char 	dev_time[32];
	char	dev_temp[10];
} packet_t;

int pack_data(packet_t *pack, char *data, int bytes);
int unpack_data(uint8_t *data, packet_t *pack);
int unpack_json(uint8_t *buf, packet_t *pack);
typedef int (* parse_proc_t)(uint8_t *buf, packet_t *pack);
int unpack_tlv(uint8_t *buf, packet_t *pack);
static uint16_t crc_itu_t(const uint8_t *data, size_t length);

#endif
